package com.anycc.cloud.core.repository;

import com.anycc.cloud.core.entity.Account;
import com.anycc.cloud.core.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * Account工厂类
 */
public interface AccountRepository extends JpaRepository<Account, String>, JpaSpecificationExecutor<Account> {

    /**
     * find account by username
     *
     * @param username username
     * @return Account
     */
    Account findByUsername(String username);

    /**
     * count account by id
     *
     * @param orgId orgId
     * @return count number
     */
    long countByOrgId(String orgId);

    /**
     * find account by role id
     *
     * @param roleId roleId
     * @return List
     */
    List<Account> findByRolesId(String roleId);

}
